package com.touchalachs.core.ui;

import android.graphics.Point;
import android.view.MotionEvent;

public abstract class TippableBasicUIElement extends BasicUIElement{

	/**
	 * params in % [0..100]
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param screenSize
	 */
	public TippableBasicUIElement(int x, int y, int w, int h, Point screenSize) {
		super(x, y, w, h, screenSize);
	}

	@Override
	public final boolean onTouchEvent(MotionEvent event){
		if (event.getAction() == MotionEvent.ACTION_DOWN){
			for (int i=0; i<event.getPointerCount(); i++){
				int x = (int) event.getX(i);
				int y = (int) event.getY(i);
				if (isInBounds(x, y) && tipp(x, y)){
					return true;
				}
			}
		}
		return false;
	}

	/**
	 * absolute pixel
	 * @param x
	 * @param y
	 * @return
	 */
	protected abstract boolean tipp(int x, int y);
	
}
